// core/init_ip_searcher.go
package core

import (
	"github.com/lionsoul2014/ip2region/binding/golang/xdb"
	"github.com/sirupsen/logrus"
	"muziai-server/global"
	"strings"
)

func InitIpSearcher() {
	var dbPath = "init/ip2region.xdb"
	searcher, err := xdb.NewWithFileOnly(dbPath)
	if err != nil {
		if strings.Contains(err.Error(), "The system cannot") {
			logrus.Fatalf("%s ip地址数据库文件不存在，请检查", dbPath)
		}
		logrus.Fatal(err)
	}
	global.IPSearcher = searcher
}
